package com.atguigu.tingshu.order.mapper;

import com.atguigu.tingshu.model.order.OrderInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface OrderInfoMapper extends BaseMapper<OrderInfo> {

    @Select("SELECT\n" +
            "\tcount(*) \n" +
            "FROM\n" +
            "\t`order_info` \n" +
            "INNER JOIN order_detail\n" +
            "ON order_info.id=order_detail.order_id\n" +
            "WHERE\n" +
            "order_status = '0901' \n" +
            "AND item_type=#{itemType}\n" +
            "AND order_detail.item_id=#{albumId}\n" +
            "AND user_id = #{userId}\n" +
            "AND order_info.is_deleted=0")
    int checkAlbumAndVipTypeItemPadding(@Param("itemType") String itemType, @Param("userId") Long userId, @Param("albumId") Long albumId);
    @Select(" SELECT \n" +
            " order_detail.item_id\n" +
            " FROM `order_info`\n" +
            " INNER JOIN order_detail\n" +
            " ON order_info.id=order_detail.order_id\n" +
            " WHERE  order_info.user_id=#{userId}\n" +
            " AND order_info.item_type=#{itemType}\n" +
            " AND order_info.order_status='0901'")
    List<Long> checkTrackTypeItemPadding(@Param("itemType") String itemType, @Param("userId") Long userId);

    int updateOrderStatus(@Param("orderNo") String orderNo);

    void cancelOrder(@Param("orderNo") String orderNo);
}
